<?php

/**
 * This is the model class for table "tbl_taxcodes".
 *
 * The followings are the available columns in table 'tbl_taxcodes':
 * @property string $code
 * @property string $taxdesc
 * @property integer $sales
 * @property string $account
 * @property string $accountdesc
 * @property double $rate
 * @property string $vendor
 * @property string $costacct
 * @property integer $piggy
 * @property integer $labor1
 * @property integer $material1
 * @property integer $other1
 * @property integer $servagr1
 */
class Taxcodes extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Taxcodes the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_taxcodes';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('code, taxdesc, sales, account, accountdesc, rate, vendor, piggy', 'required'),
			array('sales, piggy, labor1, material1, other1, servagr1', 'numerical', 'integerOnly'=>true),
			array('rate', 'numerical'),
			array('code', 'length', 'max'=>8),
			array('taxdesc, accountdesc', 'length', 'max'=>50),
			array('account', 'length', 'max'=>15),
			array('vendor', 'length', 'max'=>4),
			array('costacct', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('code, taxdesc, sales, account, accountdesc, rate, vendor, costacct, piggy, labor1, material1, other1, servagr1', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'code' => 'Code',
			'taxdesc' => 'Taxdesc',
			'sales' => 'Sales',
			'account' => 'Account',
			'accountdesc' => 'Accountdesc',
			'rate' => 'Rate',
			'vendor' => 'Vendor',
			'costacct' => 'Costacct',
			'piggy' => 'Piggy',
			'labor1' => 'Labor1',
			'material1' => 'Material1',
			'other1' => 'Other1',
			'servagr1' => 'Servagr1',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('code',$this->code,true);
		$criteria->compare('taxdesc',$this->taxdesc,true);
		$criteria->compare('sales',$this->sales);
		$criteria->compare('account',$this->account,true);
		$criteria->compare('accountdesc',$this->accountdesc,true);
		$criteria->compare('rate',$this->rate);
		$criteria->compare('vendor',$this->vendor,true);
		$criteria->compare('costacct',$this->costacct,true);
		$criteria->compare('piggy',$this->piggy);
		$criteria->compare('labor1',$this->labor1);
		$criteria->compare('material1',$this->material1);
		$criteria->compare('other1',$this->other1);
		$criteria->compare('servagr1',$this->servagr1);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}